package com.wxzz.elearing.livetelecast.api.docent;

import com.alibaba.fastjson.JSONObject;
import com.wxzz.elearing.livetelecast.dto.PlatformLivetelecastDto;
import com.wxzz.elearing.livetelecast.entity.PlatformLivetelecast;
import com.wxzz.elearing.livetelecast.service.ILivetelecastCategoryService;
import com.wxzz.elearing.livetelecast.service.IPlatformLivetelecastService;
import com.wxzz.elearning.common.vo.JgPageVo;
import com.wxzz.elearning.common.vo.ReturnVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/docent-livetelecast")
@Api(tags = "直播接口(讲师端)")
public class DocentLivetelecast {

    @Autowired
    private ILivetelecastCategoryService livetelecastCategoryService;

    @Autowired
    private IPlatformLivetelecastService platformLivetelecastService;

    @Autowired
    private RedisTemplate<String, String> redisTemplate;

    @ApiOperation(value = "平台直播列表(总后台)", notes = "平台直播列表(总后台)", httpMethod = "POST", tags = "总后台")
    @RequestMapping(value = "listPlatformLivetelecast", method = RequestMethod.POST)
    public ReturnVO<JgPageVo<List<PlatformLivetelecast>>> listPlatformLivetelecast(@RequestHeader String token, @RequestBody PlatformLivetelecastDto platformLivetelecastDto) {
        JSONObject jsonObject = JSONObject.parseObject(redisTemplate.opsForValue().get(token));
        platformLivetelecastDto.setDocentId(jsonObject.getLong("docentId"));
        return platformLivetelecastService.listPlatformLivetelecast(platformLivetelecastDto);
    }

}
